package sample.com.imagecompress;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import sample.com.imagecompress.mamera.activity.MameraActivity;

public class CameraSwitchActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_mamera;

    public static final int REQUEST_MAMERA_CAPTURE = 11000;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_camera_switch);

        btn_mamera = findViewById(R.id.btn_mamera);
        btn_mamera.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_mamera:
                Intent intent = new Intent(CameraSwitchActivity.this, MameraActivity.class);
                startActivityForResult(intent, REQUEST_MAMERA_CAPTURE);
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (REQUEST_MAMERA_CAPTURE == requestCode) {
            if (RESULT_OK == resultCode) {
                if (data != null) {
                    String path = data.getStringExtra(MameraActivity.EXTRA_FILE_PATH);
                    Toast.makeText(this, "path:" + path, Toast.LENGTH_SHORT).show();
                }
            }
        }
    }
}
